package model;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Model;

/**
 * Created by BaiYunfei on 2017/6/14.
 */
public class StudentCourse extends Model<StudentCourse> {

    public static final StudentCourse dao = new StudentCourse();
    
    @Override
    public boolean update(){
    	Db.update("UPDATE SC "
    			+ "SET Student_ID=? , Course_ID=?, Grade=? "
    			+ "WHERE Student_ID=? AND Course_ID=?", 
    			get("Student_ID"), 
    			get("Course_ID"), 
    			get("Grade"),
    			get("Student_ID"), 
    			get("Course_ID"));
    	return true;
    }
    
    @Override
    public boolean save(){
    	return Db.update("INSERT INTO SC ([Student_ID],[Course_ID],[Grade]) VALUES(?,?,?)",
    			getStr("Student_ID"),
    			getStr("Course_ID"),
    			getInt("Grade")) > 0;
    }

}
